﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using UtilityLibrary.WinControls;
namespace CKNetFrameWork
{
    public partial class Frm_MainToolWindow : DockContent
    {
        //private void AddNewItem(ref OutlookBarBand outlookShortcutsBand,string strName, ref int nIndex)
        //{
        //    if (Program.gc.HasFunction(strName))
        //        outlookShortcutsBand.Items.Add(new OutlookBarItem(strName, nIndex++));
        //}
        
         private void InitializeOutlookbar()
        {

       
            foreach (string strModule in Frm_Main.m_dicFormText2FormTypeName.Keys)
            {
                OutlookBarBand outlookShortcutsBand = new OutlookBarBand(strModule);
                outlookShortcutsBand.SmallImageList = this.imageList;
                outlookShortcutsBand.LargeImageList = this.imageList;
                int nImageIndex = 0;
                foreach (string strItem in Frm_Main.m_dicFormText2FormTypeName[strModule].Keys)
                {
                    outlookShortcutsBand.Items.Add(new OutlookBarItem(strItem, nImageIndex++));
                    outlookShortcutsBand.Background = SystemColors.AppWorkspace;
                    outlookShortcutsBand.TextColor = Color.White;

                }

                outlookBar1.Bands.Add(outlookShortcutsBand);
            }
            //outlookBar1 = new OutlookBar();
            //如果不能disable，就在加载的时候根据权限选择加载或不加载
            //#region 销售管理

            //int nIndex = 0;
            //OutlookBarBand outlookShortcutsBand = new OutlookBarBand("资料管理");
            //outlookShortcutsBand.SmallImageList = this.imageList;
            //outlookShortcutsBand.LargeImageList = this.imageList;
            
            //nIndex = 0;
            //AddNewItem(ref outlookShortcutsBand, "产品管理", ref nIndex);
            //AddNewItem(ref outlookShortcutsBand, "区域管理", ref nIndex);
            //AddNewItem(ref outlookShortcutsBand, "代理商管理", ref nIndex);
            //AddNewItem(ref outlookShortcutsBand, "零售商管理", ref nIndex);
            ////outlookShortcutsBand.Items.Add(new OutlookBarItem("产品管理", 0));
            ////outlookShortcutsBand.Items.Add(new OutlookBarItem("区域管理", 1));
            ////outlookShortcutsBand.Items.Add(new OutlookBarItem("代理商管理", 2));
            ////outlookShortcutsBand.Items.Add(new OutlookBarItem("零售商管理", 3));
             

            //outlookShortcutsBand.Background = SystemColors.AppWorkspace;
            //outlookShortcutsBand.TextColor = Color.White;
            //outlookBar1.Bands.Add(outlookShortcutsBand);


            //OutlookBarBand outlookShortcutsBand4 = new OutlookBarBand("订单管理");
            //outlookShortcutsBand4.SmallImageList = this.imageList;
            //outlookShortcutsBand4.LargeImageList = this.imageList;
            
            //nIndex = 0;
            //AddNewItem(ref outlookShortcutsBand4, "订单管理", ref nIndex);

            ////outlookShortcutsBand4.Items.Add(new OutlookBarItem("订单管理", 0));



            //outlookShortcutsBand4.Background = SystemColors.AppWorkspace;
            //outlookShortcutsBand4.TextColor = Color.White;
            //outlookBar1.Bands.Add(outlookShortcutsBand4);


            //OutlookBarBand outlookShortcutsBand2 = new OutlookBarBand("财务管理");
            //outlookShortcutsBand2.SmallImageList = this.imageList;
            //outlookShortcutsBand2.LargeImageList = this.imageList;
            //AddNewItem(ref outlookShortcutsBand2, "充值管理", ref nIndex);
            ////outlookShortcutsBand2.Items.Add(new OutlookBarItem("充值管理", 0));



            //outlookShortcutsBand2.Background = SystemColors.AppWorkspace;
            //outlookShortcutsBand2.TextColor = Color.White;
            //outlookBar1.Bands.Add(outlookShortcutsBand2);


            //OutlookBarBand outlookShortcutsBand3 = new OutlookBarBand("库房管理");
            //outlookShortcutsBand3.SmallImageList = this.imageList;
            //outlookShortcutsBand3.LargeImageList = this.imageList;
            //AddNewItem(ref outlookShortcutsBand3, "入库管理", ref nIndex);
            ////outlookShortcutsBand3.Items.Add(new OutlookBarItem("入库管理", 0));



            //outlookShortcutsBand3.Background = SystemColors.AppWorkspace;
            //outlookShortcutsBand3.TextColor = Color.White;
            //outlookBar1.Bands.Add(outlookShortcutsBand3);
             
            //#endregion





         
         

            //#endregion
            outlookBar1.Dock = DockStyle.Fill;
            outlookBar1.SetCurrentBand(0);
            //OutlookBarBand bb = outlookBar1.Bands[1];
            // bb.Items[0]
            outlookBar1.ItemClicked += new OutlookBarItemClickedHandler(OnOutlookBarItemClicked);
            outlookBar1.ItemDropped += new OutlookBarItemDroppedHandler(OnOutlookBarItemDropped);

            //outlookBar1.FlatArrowButtons = true;
            this.panel1.Controls.AddRange(new Control[] { outlookBar1 });
        }
         
        private void OnOutlookBarItemClicked(OutlookBarBand band, OutlookBarItem item)
        {
            Frm_Main.GetMainForm().ShowContent(item.Text);
            //switch (item.Text)
            //{
            //    #region 资料管理
            //    case "工厂管理":
            //        {
            //            Frm_Main.GetMainForm().ShowContent(item.Text);
                        
            //        }
            //        break;


            //    #endregion

            //    #region 业务管理
            //    case "派单管理":
            //        Frm_Main.GetMainForm().ShowContent(item.Text);
            //        break;
            //    case "商检装箱单":
            //        Frm_Main.GetMainForm().ShowSJFillBoxSheetForm();
            //        break;
            //    case "商检合同及发票":
            //        Frm_Main.GetMainForm().ShowSJContractForm();
            //        break;
            //    case "购货合同草稿":
            //        Frm_Main.GetMainForm().ShowSJBuyGoodsForm();
            //        break;
            //    case "报关装箱单":
            //        Frm_Main.GetMainForm().ShowSJBuyGoodsForm();
                    
            //        break;
            //    #endregion



            //    default:
            //        break;
            //}
        }

         private void OnOutlookBarItemDropped(OutlookBarBand band, OutlookBarItem item)
         {
             //            string message = "Item : " + item.Text + " was dropped";
             //            MessageBox.Show(message);            
         }
         public Frm_MainToolWindow()
        {
            
            InitializeComponent();
            InitializeOutlookbar();
        }

         private void Frm_MainToolWindow_Load(object sender, EventArgs e)
         {

         }
    }
}
